This patch, backported from upstream by Aurelien Jarno
<aurel32@debian.org>, has been added:
Always define gmalloc etc. in src/gmalloc.c
This is a work-around to prevent the compiler from using semantic
knowledge about malloc for optimization purposes. E.g., gcc 5.2
with -O2 replaces most of calloc's definition by a call to calloc;
see Bug#22085.
* src/gmalloc.c [!HYBRID_MALLOC] (malloc, realloc, calloc)
(aligned_alloc, free): Do not undef. Instead, define these as
functions (perhaps renamed to gmalloc etc.) in terms of gmalloc etc.
Origin: backport, commit:
4b1436b702d56eedd27a0777fc7232cdfb7ac4f6
Bug-Debian: http://bugs.debian.org/833727
Added-by: Rob Browning <rlb@defaultvalue.org>
#include <stddef.h>
+#undef malloc
+#undef realloc
+#undef calloc
+#undef aligned_alloc
+#undef free
+#define malloc gmalloc
+#define realloc grealloc
+#define calloc gcalloc
+#define aligned_alloc galigned_alloc
+#define free gfree
+#define malloc_info gmalloc_info
/* Allocate SIZE bytes of memory. */
extern void *malloc (size_t size);
return aligned_alloc (pagesize, size);
}
+#undef malloc
+#undef realloc
+#undef calloc
+#undef aligned_alloc
+#undef free
+
+void *
+malloc (size_t size)
+{
+ return gmalloc (size);
+}
+
+void *
+calloc (size_t nmemb, size_t size)
+{
+ return gcalloc (nmemb, size);
+}
+
+void
+free (void *ptr)
+{
+ gfree (ptr);
+}
+
+void *
+aligned_alloc (size_t alignment, size_t size)
+{
+ return galigned_alloc (alignment, size);
+}
+
+void *
+realloc (void *ptr, size_t size)
+{
+ return grealloc (ptr, size);
+}
+
#ifdef GC_MCHECK
/* Standard debugging hooks for `malloc'.